#ifndef Algebra_MpiGraphCommunicator_h
#define Algebra_MpiGraphCommunicator_h

#include "MpiCommunicator.h"
#include "Graph.h"

SG_NAMESPACE_OPEN
namespace Algebra
{
    /**
     * @brief An MPI communicator with a graph topology.
     *
     * Large-scale numerical simulations on parallel computers, such as those based on finite element methods,
     * require the distribution of the finite element mesh to the processors. This distribution must be done
     * so that the number of elements assigned to each processor is the same, and the number of adjacent
     * elements assigned to different processors is minimized. The goal of the first condition is to balance
     * the computations among the processors. The goal of the second condition is to minimize the communication
     * resulting from the placement of adjacent elements to different processors.
     *
     * @see George Karypis. METIS: A Software Package forPartitioning Unstructured Graphs, Partitioning Meshes,
     * and Computing Fill-Reducing Orderings of Sparse Matrices.
     *
     * @author nene
     * @date December, 2024.
     */
    class ALGEBRA_EXPORT MpiGraphCommunicator : public MpiCommunicator
    {
    public:
        MpiGraphCommunicator (const MPI_Comm& comm, const Graph& graph);
        ~MpiGraphCommunicator ();

    protected:
        void setup (const MPI_Comm& comm, const Graph& graph);
    };
}  // namespace Algebra

SG_NAMESPACE_CLOSE

#endif  //  Algebra_MpiGraphCommunicator_h